package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView.LayoutParams;
import com.huawei.appgallery.foundation.card.base.bean.BaseDistCardBean;
import com.huawei.appgallery.foundation.card.gamereserve.bean.OrderAppCardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.button.DownloadButton;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.framework.widget.TagRenderTextView;
import com.huawei.appmarket.service.store.awk.widget.horizon.HorizontalCardConfig;
import o.cgz;
import o.chy;
import o.eqx;
import o.evx;
import o.ewm.d;
import o.ewm.j;

public class BaseHorizontalAppItemCard extends BaseHorizontalItemCard {
    private int ʻ;
    private int ʼ;
    private int ʽ;
    private int ˊॱ;
    protected RelativeLayout ˋ;
    private int ॱॱ;
    private int ᐝ;

    public BaseHorizontalAppItemCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ˏ((ImageView) view.findViewById(j.ʻˊ));
        ˊ((ImageView) view.findViewById(j.ꜞˋ));
        ॱ((TextView) view.findViewById(j.ʽ));
        ˊ((TextView) view.findViewById(j.ˋ));
        ˋ((DownloadButton) view.findViewById(j.ᵣ));
        this.ˋ = (RelativeLayout) view.findViewById(j.ʼﾟ);
        ʽ(view);
        Context context = view.getContext();
        this.ʽ = ॱ(context);
        this.ʻ = (int) ˏ(ˊˋ().getTextSize());
        this.ॱॱ = (int) ˏ(ˋˊ().getTextSize());
        this.ᐝ = ʽ().getLayoutParams().height;
        this.ʼ = context.getResources().getDimensionPixelSize(d.ᐨ);
        this.ˊॱ = context.getResources().getDimensionPixelSize(d.ᐧ);
        return this;
    }

    protected boolean ʼ() {
        return false;
    }

    public void ॱ(BaseDistCardBean baseDistCardBean) {
        if (this.ˊ == null) {
            return;
        }
        if (ʼ()) {
            this.ˊ.setVisibility(0);
            this.ˊ.setParam(baseDistCardBean);
            ॱ(this.ˊ.ॱ());
            return;
        }
        this.ˊ.setVisibility(8);
    }

    protected int ॱ(Context context) {
        return context.getResources().getDimensionPixelSize(d.ʻ);
    }

    public int ˊ() {
        return 0;
    }

    public int ˎ() {
        return 0;
    }

    public void x_() {
        if (this.ˊᐝ instanceof OrderAppCardBean) {
            int ˊ;
            int ˋ;
            int i;
            CharSequence O_;
            OrderAppCardBean orderAppCardBean = (OrderAppCardBean) this.ˊᐝ;
            if (this.ˊᐝ.ॱꜞ() instanceof HorizontalCardConfig) {
                HorizontalCardConfig horizontalCardConfig = (HorizontalCardConfig) this.ˊᐝ.ॱꜞ();
                ˊ = horizontalCardConfig.ˊ();
                ˋ = horizontalCardConfig.ˋ();
                i = ˊ;
            } else {
                ˋ = 1;
                i = 1;
            }
            int ͺ = orderAppCardBean.ͺ();
            this.ʿ.setMaxLines(i);
            String str = "";
            LayoutParams layoutParams = (LayoutParams) this.ˋ.getLayoutParams();
            if (ͺ == 4) {
                O_ = orderAppCardBean.O_();
                ˊ = 0;
            } else if (TextUtils.isEmpty(orderAppCardBean.ˏˎ())) {
                r7 = str;
                ˊ = 8;
            } else {
                r7 = orderAppCardBean.ˏˎ();
                ˊ = 0;
            }
            this.ˉ.setVisibility(ˊ);
            if (ˊ == 8) {
                ˋ = 0;
            } else {
                this.ˉ.setMaxLines(ˋ);
                if (this.ˉ instanceof TagRenderTextView) {
                    ((TagRenderTextView) this.ˉ).setData(O_, orderAppCardBean.ˋʻ(), this.ˊॱ);
                } else {
                    this.ˉ.setText(O_);
                }
            }
            int i2 = ((this.ʽ + this.ʼ) + (this.ʻ * i)) + (this.ॱॱ * ˋ);
            if (ʼ()) {
                i2 += this.ʼ + this.ᐝ;
            }
            layoutParams.height = i2;
        }
    }

    public void ॱ(final chy o_chy) {
        OnClickListener anonymousClass5 = new evx(this) {
            final /* synthetic */ BaseHorizontalAppItemCard ˋ;

            public void ˋ(View view) {
                o_chy.ˏ(0, this.ˋ);
            }
        };
        ʼॱ().setOnClickListener(anonymousClass5);
        ˉ().setOnClickListener(anonymousClass5);
    }

    public void w_() {
        if (TextUtils.isEmpty(this.ˊᐝ.ॱˑ())) {
            eqx.ˏ(this.ʽॱ, this.ˊᐝ.ॱˌ(), "app_default_icon");
        } else {
            eqx.ॱ(this.ʽॱ, this.ˊᐝ.ॱˑ(), "app_default_icon");
        }
        this.ʽॱ.setContentDescription(this.ˊᐝ.v_());
    }
}
